# from socket import *
#
# client = socket(AF_INET, SOCK_DGRAM)
#
# client.sendto(b'hello', ('127.0.0.1', 8080))
# client.sendto(b'world', ('127.0.0.1', 8080))
#
# client.close()

from socket import *

client = socket(AF_INET, SOCK_DGRAM)

while True:
    msg = input('>>: ').strip()
    # 发送消息
    client.sendto(msg.encode('utf-8'), ('127.0.0.1', 8080))
    # 接收消息
    data, server_addr = client.recvfrom(1024)
    print(data, server_addr)
client.close()
